package com.sk.myview;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView;
import com.sk.myview.TaskListAdapter;
public class TaskList extends ListView{
	private List<HashMap<String, String>> setedData;
	private int configID;
	private Context context;
	
	public TaskList(Context context) {
		super(context);
		this.context = context;
		
	}
	public TaskList(Context context,AttributeSet attributeSet) {
		super(context,attributeSet);
		this.context = context;
	}
	public void setConfigID(int configID){
		this.configID = configID;
	}
	public int getConfigID(){
		return configID;
	}
	public void setMylistAdapter(List<HashMap<String, String>> getedData,List<String> tagList,String tagName){
		TaskListAdapter taskListAdapter = new TaskListAdapter(context, changeData(getedData, tagList, tagName), tagList, tagName);
		setAdapter(taskListAdapter);
	}
	public List<HashMap<String, String>> changeData(List<HashMap<String, String>> receivedData,List<String> receivedTag,String tagName){
		setedData = new ArrayList<HashMap<String,String>>();
		for(int i =0;i<receivedTag.size();i++){
			String tagString = receivedTag.get(i);
			HashMap<String, String> map1 = new HashMap<String, String>();
			map1.put(tagName, tagString);
			setedData.add(map1);
			for(HashMap<String, String> map2:receivedData){
				if(map2.get(tagName).equals(tagString)){
					HashMap<String, String> map3 = (HashMap<String, String>)map2.clone();
					map3.put(tagName, "");
					setedData.add(map3);
				}
			}
		}
		return setedData;
	}		
}
